/**
 * @author SilverBiology, LLC
 * @website http://code.google.com/p/gbif-spreadsheet-processor/
*/
Ext.namespace('GBIF');
Ext.namespace('GBIF.GeoSpatial')

GBIF.GeoSpatial.MapComponent = function(config){

	var mercator = new OpenLayers.Projection("EPSG:900913");

	var options = {
			projection: mercator
		,	units: "m"
//		,	maxResolution: 1.40625
		,	maxResolution: "auto"
		,	maxExtent: new OpenLayers.Bounds(-180, -90,180, 90)
	};

	this.scaleline = new OpenLayers.Control.ScaleLine({
			autoActivate: false
		,	allowSelection: true	
	});
	
	this.navigation = new OpenLayers.Control.Navigation({zoomBoxEnabled:true});
	
	this.panzoombar = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(5,20)});
	
	this.mouseposition = new OpenLayers.Control.MousePosition(); 
	
	var baseMap = new OpenLayers.Layer.WMS(
			"World Map"
		,	Config.General.baseMapSettings.url
		,	{layers: Config.General.baseMapSettings.layers,	isBaseLayer: true }
	);

	this.overviewmap = new OpenLayers.Control.OverviewMap();

	Ext.apply(this, config, {
	    layout: Config.GBIF.GeoSpatial.MapComponent.layout
		,	bodyStyle: Config.GBIF.GeoSpatial.MapComponent.bodyStyle
		,	border: Config.GBIF.GeoSpatial.MapComponent.border
		,	zoom: Config.GBIF.GeoSpatial.MapComponent.zoom
		,	map:  new OpenLayers.Map('map',{
					controls: [	
							this.navigation
						,	this.panzoombar
						,	this.scaleline
						,	this.mouseposition
						,	this.overviewmap
					]
				,	numZoomLevels: 15
				,	options:options
			}) 
		,	layers: [ baseMap ]
		,	listeners: {
				afterrender:function(){
//					this.overviewmap.element.className = 'gbif-olControlOverviewMapElement';
//					this.overviewmap.minimizeDiv.className = 'gbif-olControlOverviewMapMinimizeButton';
//					this.overviewmap.maximizeDiv.className = 'gbif-olControlOverviewMapMaximizeButton';
				}
			}	
	});

	GBIF.GeoSpatial.MapComponent.superclass.constructor.call(this,config);
}

Ext.extend(GBIF.GeoSpatial.MapComponent, GeoExt.MapPanel, {		
});